//===----------------------------------------------------------------------===//
//
// This source file is part of the Soto for AWS open source project
//
// Copyright (c) 2017-2021 the Soto project authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
// See CONTRIBUTORS.txt for the list of Soto project authors
//
// SPDX-License-Identifier: Apache-2.0
//
//===----------------------------------------------------------------------===//

// THIS FILE IS AUTOMATICALLY GENERATED by https://github.com/soto-project/soto/tree/main/CodeGenerator. DO NOT EDIT.

import SotoCore

/// Error enum for Imagebuilder
public struct ImagebuilderErrorType: AWSErrorType {
    enum Code: String {
        case callRateLimitExceededException = "CallRateLimitExceededException"
        case clientException = "ClientException"
        case forbiddenException = "ForbiddenException"
        case idempotentParameterMismatchException = "IdempotentParameterMismatchException"
        case invalidPaginationTokenException = "InvalidPaginationTokenException"
        case invalidParameterCombinationException = "InvalidParameterCombinationException"
        case invalidParameterException = "InvalidParameterException"
        case invalidParameterValueException = "InvalidParameterValueException"
        case invalidRequestException = "InvalidRequestException"
        case invalidVersionNumberException = "InvalidVersionNumberException"
        case resourceAlreadyExistsException = "ResourceAlreadyExistsException"
        case resourceDependencyException = "ResourceDependencyException"
        case resourceInUseException = "ResourceInUseException"
        case resourceNotFoundException = "ResourceNotFoundException"
        case serviceException = "ServiceException"
        case serviceQuotaExceededException = "ServiceQuotaExceededException"
        case serviceUnavailableException = "ServiceUnavailableException"
    }

    private let error: Code
    public let context: AWSErrorContext?

    /// initialize Imagebuilder
    public init?(errorCode: String, context: AWSErrorContext) {
        guard let error = Code(rawValue: errorCode) else { return nil }
        self.error = error
        self.context = context
    }

    internal init(_ error: Code) {
        self.error = error
        self.context = nil
    }

    /// return error code string
    public var errorCode: String { self.error.rawValue }

    /// You have exceeded the permitted request rate for the specific operation.
    public static var callRateLimitExceededException: Self { .init(.callRateLimitExceededException) }
    /// These errors are usually caused by a client action, such as using an action or resource on behalf of a user that doesn't have permissions to use the action or resource, or specifying an invalid resource identifier.
    public static var clientException: Self { .init(.clientException) }
    /// You are not authorized to perform the requested operation.
    public static var forbiddenException: Self { .init(.forbiddenException) }
    /// You have specified a client token for an operation using parameter values that differ from a previous request that used the same client token.
    public static var idempotentParameterMismatchException: Self { .init(.idempotentParameterMismatchException) }
    /// You have provided an invalid pagination token in your request.
    public static var invalidPaginationTokenException: Self { .init(.invalidPaginationTokenException) }
    /// You have specified two or more mutually exclusive parameters. Review the error message for details.
    public static var invalidParameterCombinationException: Self { .init(.invalidParameterCombinationException) }
    /// The specified parameter is invalid. Review the available parameters for the API request.
    public static var invalidParameterException: Self { .init(.invalidParameterException) }
    /// The value that you provided for the specified parameter is invalid.
    public static var invalidParameterValueException: Self { .init(.invalidParameterValueException) }
    /// You have made a request for an action that is not supported by the service.
    public static var invalidRequestException: Self { .init(.invalidRequestException) }
    /// Your version number is out of bounds or does not follow the required syntax.
    public static var invalidVersionNumberException: Self { .init(.invalidVersionNumberException) }
    /// The resource that you are trying to create already exists.
    public static var resourceAlreadyExistsException: Self { .init(.resourceAlreadyExistsException) }
    /// You have attempted to mutate or delete a resource with a dependency that prohibits this action. See the error message for more details.
    public static var resourceDependencyException: Self { .init(.resourceDependencyException) }
    /// The resource that you are trying to operate on is currently in use. Review the message details and retry later.
    public static var resourceInUseException: Self { .init(.resourceInUseException) }
    /// At least one of the resources referenced by your request does not exist.
    public static var resourceNotFoundException: Self { .init(.resourceNotFoundException) }
    /// This exception is thrown when the service encounters an unrecoverable exception.
    public static var serviceException: Self { .init(.serviceException) }
    /// You have exceeded the number of permitted resources or operations for this service. For service quotas, see EC2 Image Builder endpoints and quotas.
    public static var serviceQuotaExceededException: Self { .init(.serviceQuotaExceededException) }
    /// The service is unable to process your request at this time.
    public static var serviceUnavailableException: Self { .init(.serviceUnavailableException) }
}

extension ImagebuilderErrorType: Equatable {
    public static func == (lhs: ImagebuilderErrorType, rhs: ImagebuilderErrorType) -> Bool {
        lhs.error == rhs.error
    }
}

extension ImagebuilderErrorType: CustomStringConvertible {
    public var description: String {
        return "\(self.error.rawValue): \(self.message ?? "")"
    }
}
